<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@taglib uri="/struts-tags" prefix="s"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OA协同办公系统</title>
<link type="text/css" rel="stylesheet" href="css/table.css">
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script type="text/javascript" src="js/file.js"></script>
<SCRIPT type="text/javascript" src="js/workflow.js"></SCRIPT>
<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<style type="text/css">
		body,td,th {
			background-color:white;
			font-family: "宋体";
			font-size: 12px;
		}
		</style>
<script type="text/javascript">
$(function(){
	var flowId=$("#flowId").val();
	var param={"flowId":flowId};
	$.post("initFlowFormValueWrite.action",param,function(data){
		var proportyList=data.proportyList;
		for(var i=0;i<proportyList.length;i++){
			if(proportyList[i].type=='word'){
				$("#word").removeAttr("disabled");
				var name=proportyList[i].columnName;
				$("#word").click(function(){
					draftWord(name,1);
				});
			}else if(proportyList[i].type=='upload'){
				$("#upload").removeAttr("disabled");
			}else{
				$("#"+proportyList[i].columnName).removeAttr("disabled");
				var id=$("#"+proportyList[i].columnName);
				if($(id).is("textarea")){
					$(id).attr("tableIndex","yes");
					$(id).attr("style"," width:80%; height:100px; border:1; overflow-y:auto");
					$(id).parent().append("<input type=\"button\" class=\"button_02\" onclick=\"OpenComment('"+proportyList[i].columnName+"')\" value=\"办公语\">");
					}
				if(proportyList[i].type=='org'){
				$("#"+proportyList[i].columnName).val('${sessionScope.userInfo.orgName}');
				}else if(proportyList[i].type=='user'){
				$("#"+proportyList[i].columnName).val('${sessionScope.userInfo.name}');
				}else if(proportyList[i].type=='date'){
					var myDate = new Date();
					$("#"+proportyList[i].columnName).val(myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate())
				}else if(proportyList[i].defaultValue!=''&&proportyList[i].defaultValue!='null'){
					$("#"+proportyList[i].columnName).val(proportyList[i].defaultValue);
				}
			}
		}
		var inputs=$("input[name=\"word\"]");
			if(inputs[0]!=undefined&&inputs[0]!=''){
				if($("#word").attr("disabled")){
				$("#word").removeAttr("disabled");
				$("#word").unbind("click");
				$("#word").bind('click',function(){
					draftWord(inputs[0].id,0);
				});
				}
			}
	},"json");
});
	
	function draftWord(val,type) {
		var id=$("#"+val).val();
		var url = "wordEditor.action?wordId="+id+"&proportyName="+val+"&status="+type;
		openWindow(url,screen.width,screen.height);
	}
	
	function saveText(val,id){
		$("#"+val).val(id);
	}
	
	function OpenComment(msg){
		var sign="";
		var URL = "getWorkLanAll.action?location="+msg+"&message="+sign;
		openWindow(encodeURI(encodeURI(URL)),400,300);
	}
	
	function SetVerifyComment(location,message){
		var msg=$("#"+location).val();
		if(msg==''||msg=='null'){
			$("#"+location).val(message);
		}else{
			$("#"+location).val(msg+"\n"+message);
		}
	}
function submitNextNode(id){
	var form=$("#definitionFormId").val();
	var reg=/^[0-9]*$/;
	if(form=='86'){
		var holiday=$("#jcoa_c501").val();
		if(holiday==''){
			alert("休假天数不能为空！");
			return;
		}else if(!reg.test(holiday)){
			alert("休假天数只能是数字！");
			return;
		}
	}else if(form=='341'){
		var holiday=$("#jcoa_c481").val();
		if(holiday==''){
			alert("请假天数不能为空！");
			return;
		}else if(!reg.test(holiday)){
			alert("请假天数只能是数字！");
			return;
		}
	}
	var actorType=$("#actorType").val();
	if(actorType=='2'){
		getcandidateR(id);
	}else if(actorType=='3'){
		getorguserR(id);
	}else if(actorType=='5'){
		selectUser(id);
	}else {
		nextStep('');
	}
}	
	
function setValue(value,id){
	nextStep(value);
}

$(function(){
	var form=$("#definitionFormId").val();
	if(form=='86'){
		$.post("getMyHolidayTotal.action",null,function(data){
			 var preHoliday=data.preHoliday;
			 var nowHoliday=data.nowHoliday;
			 var total=data.total;
			$("#holiday").html("去年剩余假期 "+preHoliday+" 天,今年有假期 "+nowHoliday+" 天,全年共有假期 "+(parseInt(preHoliday)+parseInt(nowHoliday))+" 天,已休假 "+total+" 天,还剩 "+(parseInt(preHoliday)+parseInt(nowHoliday)-parseInt(total))+" 天");
		},"json");
	}else if(form=='341'){
		$.post("getMyLeaveTotal.action",null,function(data){
			var leave=data.leave;
			$("#holiday").html("今年已请事假 "+leave.days1+" 天,今年已请病假 "+leave.days2+" 天");
		},"json");
	}
});

</script>
  </head>
  
<body>
<div align="center" style="color:#CC6600;font-size: 16px;" id="holiday"></div>
<input type="hidden" id="userName" value="${sessionScope.userInfo.name}">
<input id="nodeId" type="hidden"  value="${node.id}">
<input id="actorType" type="hidden" value="${node.actorType}">
<input id="definitionFormId" type="hidden" value="${definition.formId}">
<input id="tableId" type="hidden" value="${tableId}">
<form action="" method="post" name="documentForm" >
<input id="userId" type="hidden" value="${sessionScope.userInfo.id}">
<input id="flowId" type="hidden" value="${workflow.id}">
<div id="nodebutton" style="margin-left: 30px;margin-top: 10px">
		<input type="button" class="button_04" onclick="submitNextNode('${node.id}')" value="${node.name}">&nbsp;
		<input type="checkbox" value="1" name="message">短信提醒
	</div>
	${definition.content}
	<p></p>
	<div  align="center">
		<input type="button" class="button_04" onclick="submitNextNode('${node.id}')" value="${node.name}">&nbsp;
		<input type="checkbox" value="1" name="message">短信提醒
	</div>
</form>
</body>
</html>
